package MOLE;

/** 
 Class1 ��ժҪ˵����
*/
public class GetValue
{

	public static String GetCookieValue(String key)
	{

		String tmp;
		try
		{
			tmp = System.Web.HttpContext.Current.Request.Cookies[key].Value;
		}
		catch (java.lang.Exception e)
		{
			tmp = "";
		}
		 return tmp;
	}
	public static int GetCookieInt(String key)
	{
		  return GetSafeInt(GetCookieValue(key));

	}
	public static void setEncryptCookie(String key, String valuestr)
	{
		key = SSCLIB.EncryptDecrypt.EncryptMD5(key);
		System.Web.HttpContext.Current.Request.Cookies[key].Value = SSCLIB.EncryptDecrypt.EncryptDES(valuestr);

	}
	public static void setEncryptCookie(String key, String valuestr, java.time.LocalDateTime expires)
	{
		key = SSCLIB.EncryptDecrypt.EncryptMD5(key);
		System.Web.HttpContext.Current.Request.Cookies[key].Value = SSCLIB.EncryptDecrypt.EncryptDES(valuestr);
		System.Web.HttpContext.Current.Request.Cookies[key].Expires = expires;


	}
	public static String GetDecryptCookie(String key)
	{

		String tmp;
		key = SSCLIB.EncryptDecrypt.EncryptMD5(key);
		try
		{
			tmp = System.Web.HttpContext.Current.Request.Cookies[key].Value;
			tmp = SSCLIB.EncryptDecrypt.DecryptDES(tmp);
		}
		catch (java.lang.Exception e)
		{
			tmp = "";
		}
		return tmp;
	}

	public static String GetRequesValue(String key)
	{

		String tmp;
		try
		{
			tmp = System.Web.HttpContext.Current.Request[key];
		}
		catch (java.lang.Exception e)
		{
			tmp = "";
		}
		if (tmp == null)
		{
			tmp = "";
		}
		return tmp;
	}

	public static long GetRequesLong(String key)
	{
		String s = GetRequesValue(key);
		long i = 0;
		try
		{
			i = Long.parseLong(s.trim());
		}
		catch (java.lang.Exception e)
		{
		}

		return i;
	}

	public static double GetRequesDouble(String key)
	{
		String s = GetRequesValue(key);
		double i = 0;
		try
		{
			i = Double.parseDouble(s.trim());
		}
		catch (java.lang.Exception e)
		{
		}

		return i;
	}

	public static int GetRequestInt(String key)
	{
		return GetSafeInt(GetRequesValue(key));

	}

	public static int GetRequesQueryInt(String key)
	{

		int i = 0;
		try
		{
			i = Integer.parseInt(System.Web.HttpContext.Current.Request.QueryString[key].toString().trim());
		}
		catch (java.lang.Exception e)
		{

		}
		return i;

	}
	public static String GetRequesQueryString(String key)
	{

	   String i = "";
		try
		{
			i = (System.Web.HttpContext.Current.Request.QueryString[key].toString().trim());
		}
		catch (java.lang.Exception e)
		{

		}
		return i;

	}



	public static int GetSafeInt(String key)
	{
		 return GetSafeInt(key, 0);
	}

	public static int GetSafeInt(String key, int defalutInt)
	{
		int i = defalutInt;
		try
		{
			i = Integer.parseInt(key.trim());
		}
		catch (java.lang.Exception e)
		{
		}
		return i;
	}
	public static int getSafeInt(String s, int defalutInt)
	{
		int i = defalutInt;
		try
		{
			i = Integer.parseInt(s.trim());
		}
		catch (java.lang.Exception e)
		{
		}
		return i;

	}
	public static double getDouble(String s)
	{
		return getDouble(s, 0);
	}
	public static double getDouble(String s, double defalutInt)
	{
		double i = defalutInt;
		try
		{
			i = Double.parseDouble(s.trim());
		}
		catch (java.lang.Exception e)
		{
		}
		return i;

	}


	/** 
	 �õ�AppSettings�е������ַ�����Ϣ
	 
	 @param key
	 @return 
	*/
	public static String GetConfigString(String key)
	{
		String s = "";
		try
		{
			s = ConfigurationSettings.AppSettings[key];
			if (s == null)
			{
				s = "";
			}

		}
		catch (RuntimeException ee)
		{
			s = "";
		}
		return s;
	}
	//public static string Get
	/** 
	 �õ�AppSettings�е�����bool��Ϣ
	 
	 @param key
	 @return 
	*/
	public static boolean GetConfigBool(String key)
	{
		boolean result = false;
		String cfgVal = GetConfigString(key);
		if (!cfgVal.equals(null) && !cfgVal.equals(""))
		{
			try
			{
				result = Boolean.parseBoolean(cfgVal);
			}
			catch (NumberFormatException e)
			{
				// Ignore format exceptions.
			}
		}

		return result;
	}
	/** 
	 �õ�AppSettings�е�����decimal��Ϣ
	 
	 @param key
	 @return 
	*/
	public static java.math.BigDecimal GetConfigDecimal(String key)
	{
		java.math.BigDecimal result = new java.math.BigDecimal(0);
		String cfgVal = GetConfigString(key);
		if (!cfgVal.equals(null) && !cfgVal.equals(""))
		{
			try
			{
				result = java.math.BigDecimal.Parse(cfgVal);
			}
			catch (NumberFormatException e)
			{
				// Ignore format exceptions.
			}
		}

		return result;
	}
	/** 
	 �õ�AppSettings�е�����int��Ϣ
	 
	 @param key
	 @return 
	*/
	public static int GetConfigInt(String key)
	{
		int result = 0;
		String cfgVal = GetConfigString(key);
		if (!cfgVal.equals(null) && !cfgVal.equals(""))
		{
			try
			{
				result = Integer.parseInt(cfgVal);
			}
			catch (NumberFormatException e)
			{
				// Ignore format exceptions.
			}
		}

		return result;
	}


}